<template>
    <div class="sidebar">
          <div v-for="items in menulist" :key="items.id">
            <el-menu v-show="topMenu==items.route"  :default-active="onRoutes" background-color="#333a4d" router>
                <template v-for="item in items.children">
                        <el-submenu :index="item.route"  :key="item.route" v-if="item.children&&item.children[0].type!=2">
                            <template slot="title"><i :class="'el-icon-'+item.icon"></i>{{ item.name}}</template>
                            <el-menu-item v-for="(subItem,i) in item.children" :key="i" :index="subItem.route">{{ subItem.name }}
                            </el-menu-item>
                        </el-submenu>
                        <el-menu-item :index="item.route" :key="item.route" v-else-if="item.type!=2">
                            <i :class="'el-icon-'+item.icon"></i>{{ item.name}}
                        </el-menu-item>
                </template>
            </el-menu>
          </div>
    </div>
</template>
<script>

    export default {
      data () {
        return {
          items: [],
          menulist:[],
          headerTitle: ''
        }
      },
      computed: {
        onRoutes () {
          return this.$route.path.replace('/', '')
        },
        topMenu(){
          return this.$store.state.common.topMenu
        }
      },
      created(){
        //this.setMenu();
      },
      methods: {
        // setMenu() {
        //    this.bus.$on('topmenu', (id) => { this.topMenu = id })
        // },
        
      },
      mounted () {
        this.headerTitle = global.config.headerTotal;
        //this.sidebar()
        this.menulist=JSON.parse(sessionStorage.getItem('menulist'));
        // this.menulist=fn.treeDataTranslate(menulist,'id','parentId');
      }
    
    }
</script>

<style scoped lang="scss">
  
</style>
